/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.storage.api;

import com.jeesite.modules.storage.service.GoodsService;
import com.jeesite.modules.storage.common.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 商品Controller
 */
@RestController(value = "apigoods")
@RequestMapping(value = "/api/goods")
public class GoodsController extends APIController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 限时爆款
     * @param memberId 会员Id
     * @param startTime 开始时间
     * @param size 每页数量
     * @param page 页码
     * @return 限时爆款
     */
    @RequestMapping(method = RequestMethod.GET,value = "limited/query")
    @ResponseBody
    public ServerResponse<List<Map>> limitedQuery(@RequestParam(value = "memberId")String memberId, @RequestParam(value = "startTime") Date startTime, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,goodsService.getLimitedListByStartTime(memberId,startTime,size,page));
    }

    /**
     * 品牌商品
     * @param memberId 会员Id
     * @param activityId 活动Id
     * @param transActivityId 转发Id
     * @param sort 排序
     * @param direction 方向
     * @param size 每页数量
     * @param page 页码
     * @return 品牌商品
     */
    @RequestMapping(method = RequestMethod.GET,value = "brand/query")
    @ResponseBody
    public ServerResponse<List<Map>> brandQuery(@RequestParam(value = "memberId")String memberId, @RequestParam(value = "activityId") String activityId, @RequestParam(value="transActivityId") String transActivityId, @RequestParam(value = "sort") String sort, @RequestParam(value = "direction") String direction, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,goodsService.getBrandList(memberId,activityId,transActivityId,sort,direction,size,page));
    }

    /*
     * 更多素材
     * @param memberId 会员Id
     * @param goodsId 商品Id
     * @return 更多素材
     */
    @RequestMapping(method = RequestMethod.GET,value = "more")
    @ResponseBody
    public ServerResponse<Map> more(@RequestParam(value = "memberId")String memberId, @RequestParam(value = "goodsId") String goodsId){
        return ServerResponse.createBySuccess(200,goodsService.getMoreById(memberId,goodsId));
    }

    /*
     * 活动商品
     * @param memberId 会员Id
     * @param activityId 活动Id
     * @return 活动商品
     */
    @RequestMapping(method = RequestMethod.GET,value = "activity/query")
    @ResponseBody
    public ServerResponse<List<Map>> ActivityQuery(@RequestParam(value = "memberId")String memberId, @RequestParam(value = "activityId") String activityId){
        return ServerResponse.createBySuccess(200,goodsService.getListByActivityId(memberId,activityId));
    }
}
